package com.ly.geek;

import com.ly.geek.pojo.User;
import com.ly.geek.service.UserService;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author liuyang
 */
@SpringBootApplication
@RestController
public class GeekApplication {
    public static void main(String[] args) {
        SpringApplication.run(GeekApplication.class, args);
    }

    @Autowired
    private UserService userService;

    @GetMapping("add")
    public void add() {
        System.out.println("11");
        User user = new User();
        user.setName("刘备");
        user.setAge(28);
        user.setAddress("蜀国");
        userService.addUser(user);
    }

    @GetMapping("get")
    public void get() {
        System.out.println("22");
        List<User> userList = userService.selectLikeName("刘");
        userList.forEach(System.out::println);
    }
}
